package com.wangcang.widgetlibrary.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.wangcang.widgetlibrary.R;
import com.wangcang.widgetlibrary.list.AListActivity;
import com.wangcang.widgetlibrary.list.BListActivity;
import com.wangcang.widgetlibrary.list.CListActivity;
import com.wangcang.widgetlibrary.list.CheckBoxListActivity;
import com.wangcang.widgetlibrary.list.DListActivity;
import com.wangcang.widgetlibrary.list.EListActivity;
import com.wangcang.widgetlibrary.list.RadioListActivity;

/**
 *  列表Activity
 * Created by ShineF on 2017/6/21 0021.
 */

public class ListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

    private String[] mStr = new String[]{"列表A", "列表B", "列表C", "列表D", "列表E", "列表单选", "列表多选", "索引列表", "多选(二级联动)"};
    private ListView mLvContent = null;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_home);
        init();
    }

    public void init(){
        mLvContent = (ListView) findViewById(R.id.lv_list);
        initData();
    }

    public void initData(){
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mStr);
        mLvContent.setAdapter(adapter);
        mLvContent.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position){
                case 0:
                    startActivity(new Intent(this, AListActivity.class));
                    break;
                case 1:
                    startActivity(new Intent(this, BListActivity.class));
                    break;
                case 2:
                    startActivity(new Intent(this, CListActivity.class));
                    break;
                case 3:
                    startActivity(new Intent(this, DListActivity.class));
                    break;
                case 4:
                    startActivity(new Intent(this, EListActivity.class));
                    break;
                case 5:
                    startActivity(new Intent(this, RadioListActivity.class));
                    break;
                case 6:
                    startActivity(new Intent(this, CheckBoxListActivity.class));
                    break;
                case 7:
                    startActivity(new Intent(this, ContactsActivity.class));
                    break;
				case 8:
					startActivity(new Intent(this, MultiSelectActivity.class));
					break;
			}
    }
}
